// pages/workerCode/wallet.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    month:'',
    money:'',
    money_drz:'',
    list:{data:[]},
    wxids:[],
  },
  onShow() {
    this.load();
  },
  async load(){
    let res=await wx.util.post("wallet/index",{month:this.data.month,page:this.data.page});
    this.setData({
      money:res.data.money,
      money_drz:res.data.money_drz,
      list:res.data.list,
    })

    let ids=await wx.util.post("msg/get_wx_ids",{type:'worker'});
    this.setData({
      wxids:ids.data
    })
  },
  filterMonth(e){
    console.log(e)
    this.setData({
      month:e.detail.value,
      page:1,
      'list.data':[]
    })
    this.load();
  },
  toPage(e){
    let s=e.currentTarget.dataset.val;
    if(s=="tixian"){
      wx.util.showLoading();
      wx.requestSubscribeMessage({
        tmplIds: this.data.wxids,
        complete(res){
          wx.hideLoading();
          wx.navigateTo({
          url:"/pages/workerCode/"+s
          })
        }
      })
      return;
    }
    wx.navigateTo({
      url:"/pages/workerCode/"+s
    })
  }
})